<?php
include("connection.php"); 
$q=$_GET["q"];

$query = "SELECT state_name as caption , state_code  as value from states WHERE (state_name LIKE '%$q%' OR state_code LIKE '$q') LIMIT 0,10";
$arr = array();
$rs = mysql_query($query);

$i=0;
while($obj = mysql_fetch_object($rs))
{
    $arr[$i]["caption"] = $obj->caption."(".$obj->value.")";
	$arr[$i]["value"]=$obj->value;
	$i++;
}
echo json_encode($arr);
mysql_close($con);
?>
 